home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / Framewrk / FWGadgts / Sources / FWButton.cpp next >
Encoding:
Text File  |  1995-11-08  |  6.0 KB  |  191 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWButton.cpp
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWFrameW.hpp"
  11.  
  12. #ifndef FWBUTTON_H
  13. #include "FWButton.h"
  14. #endif
  15.  
  16. // ----- OpenDoc Includes -----
  17.  
  18. #ifndef SOM_ODSession_xh
  19. #include <ODSessn.xh>
  20. #endif
  21.  
  22. // ----- Foundation Includes -----
  23.  
  24. #ifndef FWSTREAM_H
  25. #include "FWStream.h"
  26. #endif
  27.  
  28. // ----- Framewrk Includes -----
  29.  
  30. #ifndef FWFRAME_H
  31. #include "FWFrame.h"
  32. #endif
  33.  
  34. #ifndef FWPART_H
  35. #include "FWPart.h"
  36. #endif
  37.  
  38. //========================================================================================
  39. // Runtime Informations
  40. //========================================================================================
  41.  
  42. #if FW_LIB_EXPORT_PRAGMAS
  43. #pragma lib_export on
  44. #endif
  45.  
  46. #ifdef FW_BUILD_MAC
  47. #pragma segment fwgadgts
  48. #endif
  49.  
  50. FW_DEFINE_CLASS_M2(FW_CButton, FW_CGadget, FW_MNotifier)
  51. FW_REGISTER_ARCHIVABLE_CLASS(FW_LButton, FW_CButton, FW_CButton::Read, FW_CGadget::Write)
  52.  
  53. //========================================================================================
  54. //    CLASS FW_CButtonPressedNotification
  55. //========================================================================================
  56.  
  57. //----------------------------------------------------------------------------------------
  58. // FW_CButtonPressedNotification::FW_CButtonPressedNotification
  59. //----------------------------------------------------------------------------------------
  60.  
  61. FW_CButtonPressedNotification::FW_CButtonPressedNotification(const FW_CInterest& interest,
  62.                                                              ODID buttonId, short buttonState) :
  63.     FW_CNotification(interest),
  64.     fButtonId(buttonId),
  65.     fButtonState(buttonState)
  66. {
  67. }
  68.  
  69. //----------------------------------------------------------------------------------------
  70. // FW_CButtonPressedNotification::FW_CButtonPressedNotification
  71. //----------------------------------------------------------------------------------------
  72.  
  73. FW_CButtonPressedNotification::FW_CButtonPressedNotification(const FW_CButtonPressedNotification& other) :
  74.     FW_CNotification(other),
  75.     fButtonId(other.fButtonId),
  76.     fButtonState(other.fButtonState)
  77. {
  78. }
  79.  
  80. //----------------------------------------------------------------------------------------
  81. // FW_CButtonPressedNotification::~FW_CButtonPressedNotification
  82. //----------------------------------------------------------------------------------------
  83.  
  84. FW_CButtonPressedNotification::~FW_CButtonPressedNotification()
  85. {
  86. }
  87.  
  88. //----------------------------------------------------------------------------------------
  89. // FW_CButtonPressedNotification::operator==
  90. //----------------------------------------------------------------------------------------
  91.  
  92. FW_Boolean FW_CButtonPressedNotification::operator==
  93.                                         (const FW_CButtonPressedNotification& other)
  94. {
  95.     return FW_CNotification::operator==(other) && 
  96.                 fButtonId == other.fButtonId &&
  97.                 fButtonState == other.fButtonState;
  98. }
  99.  
  100. //----------------------------------------------------------------------------------------
  101. // FW_CButtonPressedNotification::operator=
  102. //----------------------------------------------------------------------------------------
  103.  
  104. FW_CButtonPressedNotification& FW_CButtonPressedNotification::operator=
  105.                                         (const FW_CButtonPressedNotification& other)
  106. {
  107.     if (this == &other)
  108.         return *this;
  109.  
  110.     FW_CNotification::operator=(other);
  111.     fButtonId = other.fButtonId;
  112.     fButtonState = other.fButtonState;
  113.  
  114.     return *this;
  115. }
  116.  
  117. //========================================================================================
  118. // CLASS FW_CButton
  119. //========================================================================================
  120.  
  121. const ODType FW_CButton::kButtonPressedNotification = "FW_CButton:ButtonPressedNotification";
  122.  
  123. //----------------------------------------------------------------------------------------
  124. // FW_CButton::FW_CButton
  125. //----------------------------------------------------------------------------------------
  126.  
  127. FW_CButton::FW_CButton(Environment* ev, 
  128.                            FW_CView* container, ODID id,
  129.                         const FW_CRect& bounds) :
  130.     FW_MNotifier(),
  131.     FW_CGadget(ev, container, id, bounds),
  132.     fButtonPressedNotificationToken(0)
  133. {
  134. }
  135.  
  136. //----------------------------------------------------------------------------------------
  137. //    FW_CButton::InitializeButton
  138. //----------------------------------------------------------------------------------------
  139.  
  140. FW_CButton::FW_CButton(Environment* ev, FW_CReadableStream& archive) :
  141.     FW_MNotifier(),
  142.     FW_CGadget(ev, archive),
  143.     fButtonPressedNotificationToken(0)
  144. {    
  145. }
  146.  
  147. //----------------------------------------------------------------------------------------
  148. // FW_CButton::~FW_CButton
  149. //----------------------------------------------------------------------------------------
  150.  
  151. FW_CButton::~FW_CButton()
  152. {
  153. }
  154.  
  155. //----------------------------------------------------------------------------------------
  156. //    FW_CButton::Flatten
  157. //----------------------------------------------------------------------------------------
  158.  
  159. void FW_CButton::Flatten(FW_CWritableStream& archive) const
  160. {
  161.     FW_CGadget::Flatten(archive);
  162. }
  163.  
  164. //----------------------------------------------------------------------------------------
  165. //    FW_CButton::Read
  166. //----------------------------------------------------------------------------------------
  167.  
  168. void* FW_CButton::Read(FW_CReadableStream& archive)
  169. {
  170.     Environment* ev = ::somGetGlobalEnvironment();
  171.     return new FW_CButton(ev, archive);
  172. }
  173.  
  174. //----------------------------------------------------------------------------------------
  175. // FW_CButton::GetButtonPressedToken
  176. //----------------------------------------------------------------------------------------
  177.  
  178. ODTypeToken FW_CButton::GetButtonPressedNotificationToken(Environment* ev) const
  179. {
  180.     FW_CButton* self = (FW_CButton *) this;
  181.     
  182.     if (fButtonPressedNotificationToken == 0)
  183.     {
  184.         self->fButtonPressedNotificationToken
  185.              = GetFrame(ev)->GetPart(ev)
  186.                  ->GetSession(ev)->Tokenize(ev, kButtonPressedNotification);
  187.     }
  188.     
  189.     return fButtonPressedNotificationToken;
  190. }
  191.